/**   
* @Title: CosTypeImpl.java 
* @Package cn.hdmis.dao.imp 
* @Description: TODO
* @author pnwazgx@163.com   
* @date 2011-3-26 下午10:11:21 
* @version V1.0   
*/
package cn.hdmis.dao.impl;

import java.io.Serializable;

import org.hibernate.Query;

import cn.hdmis.dao.CostTypeDao;
import cn.hdmis.entity.CostType;
import cn.hdmis.util.HibernateUtil;

/** 
 * @ClassName: CosTypeImpl 
 * @Description: TODO 
 * @author pnwzgx@163.com
 * @date 2011-3-26 下午10:11:21 
 *  
 */

public class CosTypeDaoImpl extends BaseDaoImp<CostType> implements CostTypeDao {


	/* (非 Javadoc) 
	* <p>Title: addCostType</p> 
	* <p>Description: </p> 
	* @param type 
	* @see cn.hdmis.dao.CostTypeDao#addCostType(cn.hdmis.entity.CostType) 
	*/
	public void addCostType(CostType entity) {
		// TODO Auto-generated method stub
		super.save(entity);
	}

	/* (非 Javadoc) 
	 * <p>Title: removeCostType</p> 
	 * <p>Description: </p> 
	 * @return 
	 * @see cn.hdmis.dao.CostTypeDao#removeCostType() 
	 */
	public boolean removeCostType(CostType entity) {
		// TODO Auto-generated method stub
		del(entity.getId());
		return true;
	}
	
	public void del(CostType entity) {
		// TODO Auto-generated method stub
		del(entity.getId());
		
	}
	
	public void del(Serializable id) {
		// TODO Auto-generated method stub
		HibernateUtil.beginTransaction();
		Query query = this.getSession().createQuery("update CostType set disabled =:disabled where id =:id");
		query.setBoolean("disabled", true);
		query.setParameter("id", id);
		query.executeUpdate();
		HibernateUtil.commitTransaction();
	}
}
